/*
 * OffsprintGenerator.h
 *
 *  Created on: 29/05/2011
 *      Author: godinho
 */

#ifndef OFFSPRINTGENERATOR_H_
#define OFFSPRINTGENERATOR_H_

#include <controller/Case.h>
#include <vector>
#include <controller/CaseRecycler.h>
#include <evolutive/EventListener.h>

class OffspringGenerator {
public:
	OffspringGenerator();
	OffspringGenerator(float crossoverRate, float mutationRate): crossOverRate(crossoverRate), mutatonRate(mutatonRate){};
	virtual ~OffspringGenerator();

	virtual std::vector<Case*> generate(Case* parent1, Case* parent2, int id);

	void setEventListener(EventListener* listener);

private:

	float crossOverRate;

	float mutatonRate;

	CaseRecycler* mRecycler;

	Dna* getDna(Case* c);

	void injectDna(Case* c, Dna* dna);

    void crossOver(Dna* p1, Dna* p2, int pos);

    void mutate(Dna* dna);

    EventListener* mEventListener;

    std::vector<int> mutations;
};


#endif /* OFFSPRINTGENERATOR_H_ */
